package flc.ast.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import flc.ast.R;
import flc.ast.activity.SelPicActivity;
import flc.ast.activity.SelVideoActivity;
import flc.ast.databinding.FragmentPicEditBinding;
import flc.ast.utils.Content;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.usersys.UserSysEventProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link PicEditFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class PicEditFragment extends BaseNoModelFragment<FragmentPicEditBinding> {


    @Override
    protected int onCreate() {
        return R.layout.fragment_pic_edit;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);

        mDataBinding.ivGifMake.setOnClickListener(this);
        mDataBinding.llPicFilter.setOnClickListener(this);
        mDataBinding.llPicAdjust.setOnClickListener(this);
        mDataBinding.tvPicCrop.setOnClickListener(this);
        mDataBinding.tvPicSticker.setOnClickListener(this);
        mDataBinding.tvPicText.setOnClickListener(this);
        mDataBinding.tvPicBackground.setOnClickListener(this);
        mDataBinding.tvPicDoodle.setOnClickListener(this);
        mDataBinding.tvPicPuzzle.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivGifMake://动图制作
                startActivity(SelVideoActivity.class);
                break;
            case R.id.llPicFilter://图片滤镜
                UserSysEventProxy.getInstance().payEventWithFreeNumOfTimes(getActivity(), Content.pic_filter_key, Content.free_max,
                        isRealOk -> {
                            if (isRealOk) {
                                SelPicActivity.type = 1;
                                startActivity(SelPicActivity.class);
                            }
                        });
                break;
            case R.id.llPicAdjust://图片调节
                UserSysEventProxy.getInstance().payEventWithFreeNumOfTimes(getActivity(), Content.pic_adjust_key, Content.free_max,
                        isRealOk -> {
                            if (isRealOk) {
                                SelPicActivity.type = 2;
                                startActivity(SelPicActivity.class);
                            }
                        });
                break;
            case R.id.tvPicCrop://图片裁剪
                SelPicActivity.type = 3;
                startActivity(SelPicActivity.class);
                break;
            case R.id.tvPicSticker://图片贴纸
                SelPicActivity.type = 4;
                startActivity(SelPicActivity.class);
                break;
            case R.id.tvPicText://图片文字
                SelPicActivity.type = 5;
                startActivity(SelPicActivity.class);
                break;
            case R.id.tvPicBackground://图片背景
                SelPicActivity.type = 6;
                startActivity(SelPicActivity.class);
                break;
            case R.id.tvPicDoodle://图片涂鸦
                SelPicActivity.type = 7;
                startActivity(SelPicActivity.class);
                break;
            case R.id.tvPicPuzzle://图片拼图
                SelPicActivity.type = 8;
                startActivity(SelPicActivity.class);
                break;
        }
    }

    @Override
    protected void initData() {

    }
}